const mysql = require('mysql');
const connection = mysql.createConnection({
  host: 'localhost',
  user: 'root',
  password: 'root',
  database: 'learn_express'
});

connection.query(
  'select * from user',
  (error, results) => {
    if (error) {
      return console.error(error.message);
    }
    
    console.log(results);
    /* [
      RowDataPacket { id: 1, username: '用户a', password: 'aaa', status: 0 },
      RowDataPacket { id: 2, username: '用户b', password: 'bbb', status: 1 }
    ] */
  }
);